<?php
	session_start();
	require('game_functions.php');
	$gameid = $_POST['gameid'];
	$name = $_POST['tabname'];

	dblogin();

	
	$query = 
	"select *
	from GAMES g
	where g.gameid = ".$gameid;

	$result = mysql_query($query);
	if($row = mysql_fetch_array($result)){
		$game = $row['GAME'];
		$owner = $row['OWNER'];
		$des = $row['DES'];
		$link = $row['LINK'];
		$type = $row['TYPE'];
		$num_per_team = $row['NUM_PER_TEAM'];
		$team_per_game = $row['TEAM_PER_GAME'];
		$bring1 = $row['BRING1'];
		$bring1_num = $row['BRING1_NUM'];
		$bring2 = $row['BRING2'];
		$bring2_num = $row['BRING2_NUM'];
		$bring3 = $row['BRING3'];
		$bring3_num = $row['BRING3_NUM'];
		$bring4 = $row['BRING4'];
		$bring4_num = $row['BRING4_NUM'];
		$rule1_title = $row['RULE1_TITLE'];
		$rule1_type = $row['RULE1_TYPE'];
		$rule1_optext = $row['RULE1_OPTEXT'];
		$rule2_title = $row['RULE2_TITLE'];
		$rule2_type = $row['RULE2_TYPE'];
		$rule2_optext = $row['RULE2_OPTEXT'];
		$rule3_title = $row['RULE3_TITLE'];
		$rule3_type = $row['RULE3_TYPE'];
		$rule3_optext = $row['RULE3_OPTEXT'];
		$status = $row['STATUS'];
	}


?>

<div id="gamedetail<?php echo $gameid;?>" class="<?php echo $type; ?>" style="float:left">
	<div id="tl">
		<div id="gen_info">
			<label>Game:</label>
			<input name="game" type="text" value="<?php echo $game; ?>" />
			<label>Sub by:</label>
			<input name="owner" type="text" value="<?php echo player_name($owner); ?>" />
		</div>
		<div id="pers">
			<label>Num/Team</label>
			<label>Team/Game</label>
			<input name="num_per_team" type="text" value="<?php echo $num_per_team; ?>" />
			<input name="team_per_game" type="text" value="<?php echo $team_per_game; ?>" />
		</div>
	</div>
	<div id="description">
		<label>Description</label>
		<textarea name="desc" rows="3"><?php echo $des; ?></textarea>
	</div>

	<div id="bringneed">
		<h1> Items Needed per Game </h1>
		<div id="row">
			<input class="item" name="bring1"     type="text" value="<?php echo $bring1; ?>" />
			<input class="num"  name="bring1_num" type="text" value="<?php echo $bring1_num; ?>" />
		</div>
		<div id="row">
			<input class="item" name="bring2"     type="text" value="<?php echo $bring2; ?>" />
			<input class="num"  name="bring2_num" type="text" value="<?php echo $bring2_num; ?>" />
		</div>
		<div id="row">
			<input class="item" name="bring3"     type="text" value="<?php echo $bring3; ?>" />
			<input class="num"  name="bring3_num" type="text" value="<?php echo $bring3_num; ?>" />
		</div>
		<div id="row">
			<input class="item" name="bring4"     type="text" value="<?php echo $bring4; ?>" />
			<input class="num"  name="bring4_num" type="text" value="<?php echo $bring4_num; ?>" />
		</div>
	</div>


	<?php if($link != ''){ ?>
		<div id="blankback" style="width: 100%;">
			<iframe  width="100%" height="300px" src="<?php echo $link;?>"></iframe>
		</div>
	<?php } ?>

	<div id="rule" class="<?php echo $rule1_type; ?> ">
		<input class="title"  name="rule1_title"  type="text" value="<?php echo $rule1_title; ?>" />
		<textarea class="detail" name="rule1_optext" > <?php echo $rule1_optext; ?></textarea>
	</div>
	<div id="rule" class="<?php echo $rule2_type; ?> ">
		<input class="title"  name="rule2_title"  type="text" value="<?php echo $rule2_title; ?>" />
		<textarea class="detail" name="rule2_optext" > <?php echo $rule2_optext; ?></textarea>
	</div>
	<div id="rule" class="<?php echo $rule3_type; ?> ">
		<input class="title"  name="rule3_title"  type="text" value="<?php echo $rule3_title; ?>" />
		<textarea class="detail" name="rule3_optext" > <?php echo $rule3_optext; ?></textarea>
	</div>
</div>
